/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSMesh.h
 *
 *  Created on: 2010/02/21
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#ifndef RSMESH_H_
#define RSMESH_H_

#include "RSGeometricElement.h"

namespace Realsphere {

    class RSMesh: public Realsphere::RSGeometricElement {
        Q_OBJECT
        public:
            Q_INVOKABLE RSMesh ();
            virtual ~RSMesh ();

        public:
            RSPrimitivesElement*            GetPrimitivesElement ( unsigned int rIndex ) const;
            int                             IndexOf ( RSPrimitivesElement* rPrimitivesElement );
            unsigned int                    PrimitivesElementsSize ();
            RSPrimitivesElements            PrimitivesElements () const;
            RSPrimitivesElementsIterator    PrimitivesElementsIterator () const;
            RSVertices*                     Vertices () const;

        public slots:
            RSError                         SetVertices ( RSVertices* rVertices );
            RSError                         AddPrimitiveElement ( RSPrimitivesElement* rPrimitiveElement );
            RSError                         RemovePrimitiveElement ( RSPrimitivesElement *rPrimitiveElement );
            RSError                         RemovePrimitiveElement ( int rIndex );

        signals:
            void                            PrimitiveElementAdded ( RSPrimitivesElement* rPrimitiveElement );
            void                            PrimitiveElementRemoved ( RSPrimitivesElement* rPrimitiveElement );
            void                            VerticesAdded ( RSVertices* rVertices );
            void                            VerticesRemoved ( RSVertices* rVertices );

        protected:
            RSError                         BeforeAddChildElement ( RSElement* rChild );
            RSError                         BeforeRemoveChildElement ( RSElement* rChild );
            bool                            AfterAddChildElement ( RSElement* rChild );
            bool                            AfterRemoveChildElement ( RSElement* rChild );

        private:
            RSPrimitivesElements            mPrimitivesElements;
            RSVertices*                     mVertices;
    };

}

#endif /* RSMESH_H_ */
